/**
 * 
 * org.skatiger.jrove.component.UIInput
 * Create at 2011-1-26
 */
package org.skatiger.jrove.component;

import java.io.IOException;

import org.skatiger.jrove.ResponseWriter;
import org.skatiger.jrove.ViewContext;
import org.skatiger.jrove.renderer.Html;
import org.skatiger.jrove.renderer.Renderer;

/**
 * 
 * @author skatiger
 * 
 */
public class UIInput extends UIComponentBase {
    public static final String VALUE_KEY = "value";

    @Override
    public Renderer getRenderer(ViewContext context) {
        return new Renderer() {
            @Override
            public void encodeBegin(ViewContext context, UIComponent component)
                    throws IOException {
                ResponseWriter writer = context.getResponseWriter();
                writer.startElement(Html.INPUT_ELEM, component);
                writer.writeAttribute(Html.TYPE_ATTR, Html.INPUT_TYPE_TEXT,
                        Html.TYPE_ATTR);
                writer.writeAttribute(Html.VALUE_ATTR, component
                        .getAttributes().get(VALUE_KEY), Html.VALUE_ATTR);
                writer.endElement(Html.INPUT_ELEM);
            }
        };
    }
}
